(function($) {
	
$.fn.layout = function(options) {
	var settings = {
		header	: 'header',
		menu	: 'menu',
		master	: 'master'
	};
	
	options = options || {}; $.extend(settings, options);
	
	$("#"+settings.header).addClass("header");
	$("#"+settings.menu).addClass("menu");
	var height = $("#"+settings.menu).height() - 62;
	$("#"+settings.menu).height( height);
	$("#"+settings.master).addClass("master").height( height );
	var width = $("#"+settings.master).width() - 210;
	$("#"+settings.master).width(width);
	
	var menuContent = $("#"+settings.menu).html();
	$("#"+settings.menu).html("<div class='menu-head'><span>功能菜单</span></div><div class='menu-content'></div>");
	$(".menu-content").height(height-28).prepend(menuContent);
}

$.fn.master = function(options) {
	var height = $(".mcontent").height();
	$(".mcontent").height(height - 28);
}

/**
 * 切换复选框状态（选中/未选中）
 */
$.fn.toggleCheckbox = function(options) {
	var checkboxes = $(this);
	var selected_count = 0, unselected_count = 0;
	$.each( checkboxes, function(i, n) {
		( $(n).attr("checked") ) ? selected_count++ : unselected_count++ ; 
	});
	( selected_count <= unselected_count ) ? checkboxes.attr("checked", true) : checkboxes.attr("checked", false);
}

/**
 * 隔行隔色
 */
$.fn.striped = function(options){
	var settings = {
		type:'table',	// 类型 table/ul 默认为table
		mouseaction:false	// 鼠标动作
	};
	options = options || {}; $.extend(settings, options);
	
	$(this).addClass("striped");
	
	return this.each(function(){		
		var rowMouse;
		var rowEven;
		if(settings.type == 'ul'){
			rowEven = $("#" + this.id + " li:even");		
			rowMouse = $("#" + this.id + " li");		
		}	
		else{
			rowEven = $("#" + this.id + " tr:even");		
			rowMouse = $("#" + this.id + " tr");
		}		
		if(settings.mouseaction){ // 鼠标经过、离开
			rowMouse.mouseover(function(){
				$(this).removeClass("double");
				$(this).addClass("over");
			});
    		rowMouse.mouseout(function(){
    			$(this).removeClass("over");
    			rowEven.addClass("double");
    		});
    	}
    	rowEven.addClass("double"); // 双行
	});
};

})(jQuery);